const FILE_TYPE = {
    jpeg: 0, jpg: 0, png: 0, gif: 0, bmp: 0, webp: 0,
    mp4: 1, avi: 1, rmvb: 1, mkv: 1, mov: 1,
    0: "IMAGE", 1: "VIDEO", 2: "OTHER"
}

const getFileType = (suffix) => {
    if (suffix == undefined) return 2;
    if (typeof suffix == "string") suffix = suffix.toLowerCase();
    const fileType = FILE_TYPE[suffix];
    return fileType == undefined ? 2 : fileType;
}

const FILE_TYPE_CONTENT_TYPE = {
    "0": "image/", "1": "video/", "2": "application/octet-stream"
}

const getContentType = (filePath, fileType) => {
    let fileSuffix = filePath.substring(filePath.lastIndexOf(".") + 1)
    let contentType = FILE_TYPE_CONTENT_TYPE[fileType] + fileSuffix
    return contentType;
}

export {
    getFileType,
    getContentType
}
